<?php include("header.inc.php") ?>
<?php include("navigation.inc.php")?>       
<?php include("left.inc.php")?>     

<div id="mainContent" class="grid_7">
<!-- Giao dien giong Tintuc.php -->

	<?php 
		$idhoatdonghocsinh = $_REQUEST['id'];
		$display  = 2;
		$pagenum = $_REQUEST["page"];
		$i  = 0;
		$sql = "SELECT * FROM hoatdonglop WHERE status = 1 AND idhoatdonghocsinh = '".$idhoatdonghocsinh."' ORDER BY thoigian DESC ";
		$result=mysql_query($sql) or die("Can not query ".mysql_error($conn));
		$totalpage=ceil(mysql_num_rows($result)/$display);
		if($pagenum<=0 ||$pagenum > $totalpage)
			$pagenum=1;
			$from=($pagenum-1)*$display;
		$sql.="  LIMIT $from, $display";
		$query=mysql_query($sql)  or die("Can not query Limit".mysql_error($conn));;					
		$check = 0;
		while ($row = mysql_fetch_array($query))
		{
			$check = 1;
	?>
	<div id="tintuc" class="grid_7">
    	<div id="tieude" class="grid_7 tieude">
			<a href = "lopchitiet.php?id=<?php echo $row['idhoatdonglop'];?>"> <?php echo $row['tieude']?> </a>        	
        </div>
        <div id="thoigian" class="grid_7">
        	(<?php echo ($time = date('d-m-Y G:i:s',strtotime($row['thoigian'])));?>)
        </div>
        <div id="xemchitiet" class="grid_7">
        	<a href = "lopchitiet.php?id=<?php echo $row['idhoatdonglop'];?>"> Xem Chi Tiết >> </a>        	
        </div>
    </div>  
    <?php
		}
		if ($check != 1) { ?>
	<div id="tintuc" class="grid_7">
    	<div id="tieude" class="grid_7 tieude">
			<p>Dữ Liệu Đang Cập Nhật</p>
        </div>
        <div id="thoigian" class="grid_7"></div>
        <div id="xemchitiet" class="grid_7"></div>
    </div>  
	<?php 
		}
	?>
   	<div class="pagelist">
    	<? 
			for($i=1;$i<=$totalpage;$i++)
			{
				if($i==1) echo "<a href='lop.php?id=$idhoatdonghocsinh&page=$i'>".$i."</a>";
				else echo " | <a href='lop.php?id=$idhoatdonghocsinh&page=$i'>".$i."</a>";
			}
        ?>
    </div>     
</div>
     
<?php include("right.inc.php")?>  
<?php include("footer.inc.php")?>  

